package com.china08.yxyapi.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;

import com.china08.yxyapi.cache.YxKeyGenerator;

/**
 * Cache Config
 * 
 * @author Ertao.Fang
 *
 */
@Configuration
@EnableCaching
@EnableScheduling
public class CacheConfig {

    public static final Logger LOGGER = LoggerFactory.getLogger(CacheConfig.class);

    /** 缓存名称 */
    public static final String DEFAULT_CACHE_NAMES = "CACHE_YXY_API_YW";
    /** KEY生成器 */
    public static final String DEFAULT_KEY_GENERATOR = "YxKeyGenerator";
    /** 缓存名称:简拼 */
    public static final String DCN = DEFAULT_CACHE_NAMES;
    /** KEY生成器:简拼 */
    public static final String DKG = DEFAULT_KEY_GENERATOR;

    @Bean(name = "YxKeyGenerator")
    KeyGenerator keyGenerator() {
        KeyGenerator generator = new YxKeyGenerator();
        return generator;
    }
}
